package com.yuye.java.redis.template.impl;

import javax.annotation.Resource;

import com.yuye.java.redis.template.RedisRepositoryInterface;
import org.redisson.api.LocalCachedMapOptions;
import org.redisson.api.RBucket;
import org.redisson.api.RLocalCachedMap;
import org.redisson.api.RedissonClient;

/**
 * Redisson基础操作类
 * @author gzs
 * @version 3.0.0
 */
public class RedissonRepository implements RedisRepositoryInterface {
	
	@Resource
	private RedissonClient client;

	@Override
	public void setValue(String key, String value) {
		RBucket<Object> bucket = client.getBucket(key);
		bucket.set(value);
	}

	@Override
	public Object  getValue(final String key) {
		RBucket<Object> bucket = client.getBucket(key);
		return bucket.get();
	}
	
	@Override
	public RLocalCachedMap<Object, Object>  getLocalCachedMap(String key) {
		RLocalCachedMap<Object, Object> localCachedMap = client.getLocalCachedMap(key, LocalCachedMapOptions.defaults());
		return localCachedMap;
	}

}
